const Controller = require('egg').Controller;

class GradeController extends Controller {
  async index() {
    this.ctx.body = 'egg'
  }
  async grade() {
    const { ctx, app } = this;
    const data = await ctx.service.grade.grade()
    ctx.body = data;
  }

  async addGrade() {
    const { ctx, app } = this;
    // try {
    //   ctx.validate({
    //     stuid: { require: true },
    //     // username: { require: true },
    //     // theory: { require: true },
    //     // skill: { require: true },
    //   }, ctx.request.body);
    // } catch (error) {
    //   ctx.status = 400;
    //   ctx.body = { code: 0, msg: 'fail', error }
    //   return;
    // }
    const data = await ctx.service.grade.addGrade()
    ctx.body = data;
  }

  async updateGrade() {
    const { ctx, app } = this;
    const data = await ctx.service.grade.updateGrade()
    ctx.body = data;
  }

  async pageGrade() {
    const { ctx, app } = this;
    const data = await ctx.service.grade.pageGrade()
    ctx.body = data;
  }

  // 操作user表
  async findUsers() {
    const { ctx, app } = this;
    const data = await ctx.service.grade.findUsers()
    ctx.body = data;
  }


}

module.exports = GradeController;